package it.unibz.easytravel.itemlist;

import java.util.Vector;
// List of Items
public class ItemList extends Vector {
	
	public ItemList(){
		super();
	}
	public void add(Item i) {
		this.addElement(i);
	}
	public void remove(Item i) {
		this.removeElement(i);
	}
	// add Item by name, Item is personal
	public void add(String name){
		Item it = new Item(name, false, false);
		this.add(it);
	}
	// add NON PERSONAL Item by name
	public void addNP(String name){
		Item it = new Item(name, true, false);
		this.add(it);
	}
	// remove Item by name
	public void remove(String name){
		int size = this.size();
		Item it;
		for (int i = 0; i < size; i++) {
			it = (Item) this.elementAt(i);
			if (it.name.equalsIgnoreCase(name)) {
				this.removeElementAt(i); break; 
				}
		}
	}

	public void setItemTaken (String name){
		int size = this.size();
		Item it;
		for (int i = 0; i < size; i++) {
			it = (Item) this.elementAt(i);
			if (it.name.equalsIgnoreCase(name)) {
				it.taken = true; break; 
				}
		}
	}

	public void setItemNotTaken (String name){
		int size = this.size();
		Item it;
		for (int i = 0; i < size; i++) {
			it = (Item) this.elementAt(i);
			if (it.name.equalsIgnoreCase(name)) {
				it.taken = false; break; 
				}
		}

	}

	
}
